package wangjg.security.core.validator;

import wangjg.security.deprecated.ResourceValidator;
import wangjg.security.util.MyExpressionEvaluator;

/**
 * 
 * @author wangjg
 *
 */
public class ExpressionValidator implements ResourceValidator{

	private String expression;

	public String getExpression() {
		return expression;
	}

	public void setExpression(String expression) {
		this.expression = expression;
	}
	
	public boolean validate(Object resource, Object user){
		MyExpressionEvaluator ev = new MyExpressionEvaluator();
		ev.putVariable("resource", resource);
		ev.putVariable("user", user);
		Boolean b=(Boolean) ev.evaluate(expression);
		return b;
	}

}
